// part1:C12:12.32:ex12.32.cpp
// main.cpp
#include <string>
using std::string;
#include <fstream>
using std::ifstream;
#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
#include <cstdlib>
#include "my_TextQuery.h"
#include "../make_plural.h"

void run_Queries(ifstream &infile)
{
  // infile is will search file.
  TextQuery tq(infile);
  while (true)
  {
    cout << "enter word to look for, or q to quit: ";
    string s1;
    if (!(cin >> s1) || s1 == "q")
    {
      break;
    }
    print(cout, tq.query(s1)) << endl;
  }
}

int main(int argc, char **argv)
{
  ifstream infile;
  if (argc < 2 || !(infile.open(argv[1]), infile))
  {
    cerr << "No input file!" << endl;
    return EXIT_FAILURE;
  }
  run_Queries(infile);
  
  return 0;
}